<?php
class Component_clientreview_register extends appRain_Base_Component
{
    public function init()
    {
        App::Module('Hook')->setHookName('CSS')
                           ->setAction("register_css_code")
                           ->Register(get_class($this),"register_css_code");


        App::Module('Hook')->setHookName('UI')
                           ->setAction("client_review_placeholder")
                           ->Register(get_class($this),"add_html");

		App::Module('Hook')->setHookName('InterfaceBuilder')
                           ->setAction("update_definition")
                           ->Register(get_class($this),"interfacebuilder_update_definition");

		App::Module('Hook')->setHookName('InformationSet')
                           ->setAction("register_definition")
                           ->Register(get_class($this),"register_informationset_defination");


    }

    public function init_on_install(){}

    public function init_on_uninstall(){}

    public function register_css_code()
    {
        return App::Helper('Utility')->fetchFile($this->attachMyPath('css/styles.css'));
    }


    public function add_html($send)
    {
		$rowData = App::InformationSet('clientreview')->findAll("1 ORDER BY id DESC",Array(Array("status"=>"Active")));
		return App::Helper('Utility')->callElementByPath($this->attachMyPath('elements/markup.phtml'),array('rowData'=>$rowData));
    }

	public function interfacebuilder_update_definition($send)
    {
        if(isset($send['component']['child']))
        {
            $send['component']['child'][] = Array("title"=>"Client Review",
												"items"=>Array(array("title"=>"Add New","link"=>"/information/manage/clientreview/add"),
															   array("title"=>"Manage Reviews","link"=>"/information/manage/clientreview")));
            return $send;
        }
    }

	public function register_informationset_defination()
    {
        $srcpaths = Array();
        $srcpaths[] =   array('type'=>'clientreview',
                               'path'=>$this->attachMyPath('information_set/clientreview.xml'));
        return $srcpaths;
    }
}